{#
Copyright (c) 2020 Andy Zhou
MIT License
#}
{% if current_user.is_authenticated %}
    <div>
    {% if not current_user.is_collecting(post) %}
    <a class="btn btn-sm btn-success" href="{{ url_for('main.collect_post', id=post.id) }}">
        <i class="fa fa-heart"></i>
        {{ _('Collect') }}
    </a>
    {% else %}
        <a class="btn btn-sm btn-warning" href="{{ url_for('main.uncollect_post', id=post.id) }}">
            <i class="fa fa-ban"></i>
            {{ _('Uncollect') }}
         </a>
    {% endif %}
    {% if current_user.is_administrator() or post.author == current_user %}
        <a class="btn btn-sm btn-primary" href="{{ url_for('main.edit_post', id=post.id) }}">
            <i class="fa fa-edit"></i>
            {{ _('EDIT [ADMIN]') }}
        </a>
    {% endif %}
    {# 如果当前用户是协管员，并且文章作者没有协管员权限时，抑或当前用户是该文章作者时，显示删除按钮 #}
    {% if (current_user.can(Permission.MODERATE)  and not post.author.can(Permission.MODERATE))
        or current_user.is_administrator() or post.author == current_user %}
        <form class="inline" method="POST" action="{{ url_for('main.delete_post', id=post.id) }}"
            style="display: inline !important">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <button class="btn btn-sm btn-danger" onclick="return confirm('Are you sure?');">
                <i class="fa fa-trash"></i>   
                {{ _('DELETE [ADMIN]') }}
                </button>
            </form>
    {% endif %}
    </div>
{% endif %}
